home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 27
/
027.d81
/
all base calc
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
4KB
|
128 lines
5 h1$="[145]"+chr$(13)+""
6 h2$="[145]"+chr$(13)+""
7 vt$=""
10 rem base do-it-all
15 :
20 rem by tom phelps
23 :
24 rem university of illinois
25 rem finite math camp
27 :
40 rem
50 print"[147]";:poke53280,6:poke53281,6
80 :
95 gosub 60000
100 ans$ = "0":b3 = 0
110 for i = 1 to 4: read opr$(i): next i: data +,-,*,/
1000 rem
1010 print"[147] ";
1020 printchr$(18)" [193]ll [194]ase [195]alculator ";
1030 print" [146]"
1050 pv$ = ans$:pv = c3 + 2 *abs((c3 = 0))
1060 print "[208]revious answer :":print pv$:print"[194]ase "pv
1070 rem
1075 b1$="":a$="":opr$="":b2$="":b3$=""
1076 printvt$;:forcl=1to2
1077 print" ":next
1079 print""tab(20)"[215]hole numbers only!":printtab(26)"'exit' to quit"
1080 print "[198]irst number"chr$(13)"[183][183][183][183][183][183][183][183][183][183][183][183]"
1090 input "[206]umber ";b1$:iflen(b1$)>8then1000
1095 ifb1$=""goto1080
1100 ifb1$="exit"thenprintchr$(147):goto63000
1110 if b1$ <>"pv"then1200
1120 b1$ = pv$:b1% = pv
1130 print "[206]umber ? "b1$" "
1140 print"[194]ase ?"b1%
1190 goto 1230
1200 print ""
1210 input"[194]ase ";a$:ifa$="restart"then1075
1212 iflen(a$)>2then52000
1215 a$=left$(a$,2)
1220 b1%=val(a$):ifb1%<2orb1%>62goto1200
1230 c1=b1%
1232 x=b1%+48:ifx>57thenx=x+8
1233 forj=1tolen(b1$):bb$=mid$(b1$,j,1)
1235 ifasc(bb$)>=xthenprintvt$"[206]o way, [202]ose'! [212]here is no such number!"
1237 ifasc(bb$)>=xthenprint"[208]ress a key.";:poke198,0:wait198,1:geta$:goto1075
1238 next
1240 rem
1400 print""h1$"[157][157](+, -, *, /, =)"
1405 printh1$;
1410 print"[207]perator ";
1412 getopr$:ifopr$=""then1412
1415 if opr$ = "r" then 1075
1420 ifopr$="="thenopr=0:goto1700
1430 fori=1to4:ifopr$=opr$(i)thenopr=i: goto1470
1440 nexti
1450 goto 1400
1460 :
1470 printvt$;:forcl=1to2
1480 print" ":next
1500 print""h2$"[211]econd number"chr$(13)h2$"[183][183][183][183][183][183][183][183][183][183][183][183][183]"
1505 printh2$;
1510 input "[206]umber ";b2$:iflen(b2$)>8then52000
1515 if b2$ = "" then print:goto 1500
1520 if b2$ = "restart" then 1075
1600 print""h2$;
1605 a$=""
1610 input"[194]ase ";a$:ifa$="restart"then1075
1614 iflen(a$)>2then 52000
1620 b2%=val(a$):if b2%<2orb2%>62thenprintchr$(7):goto1600
1630 c2=b2%
1632 x=b2%+48:ifx>57thenx=x+8
1633 forj=1tolen(b2$):bb$=mid$(b2$,j,1)
1640 ifasc(bb$)>=xthenprintvt$"[206]o way, [202]ose'! [212]here is no such number!"
1650 ifasc(bb$)>=xthenprint"[208]ress a key.";:poke198,0:wait198,1:geta$:goto1460
1655 next
1700 print"[206]ow enter what base the answer should"
1705 print "be in.": print
1710 input "-> ";b3$:b3$=left$(b3$,2):ifb3$="re"then1075
1720 b3%=val(b3$):ifb3%<2orb3%>62goto1700
1730 c3=b3%
1800 gosub 5500
1805 forcl=19to4step-1:print"":forc2=1tocl:print:next
1806 print" ":next
1810 print"[193]nswer: "
1811 printspc(27-len(b1$))b1$" (base "b1%"[157])"
1812 printspc(27-len(b2$)-2)op$" "b2$" (base "b2%"[157])"
1813 forqd=1to38:print"-";:next:print
1814 iflen(an$)>26thenan$="0":52000
1815 printspc(27-len(an$))an$" (base "b3%"[157])"
1820 print"[193]ny key ";:poke198,0:wait198,1:get a$
1821 b2$="":b2% = 0
1830 goto1000
5500 bin$ = b1$:b = c1: gosub 6010:b1 = dec
5520 if opr=0then ans = b1: goto 5700
5530 bin$ = b2$:b = c2: gosub 6010:b2 = dec
5540 if opr = 1 then ans = b1 + b2
5550 if opr = 2 then ans = b1 - b2
5560 if opr = 3 then ans = b1 * b2
5570 if opr = 4 then ifb2<>0thenans = b1 / b2:goto5700
5580 if opr=4thenprint" [196]on't divide by zero...":fordl=1to1000:next:goto1000
5700 dec = ans:b = c3: gosub 6000
5710 ans$ = bin$: return
6000 bin$="":fori=0to1step0:r=int(((dec/b-int(dec/b))*b)+.0001)
6003 bin$=chr$(r+abs((r<10))*48+abs((r>9))*55)+bin$
6004 dec=int(dec/b):i=abs((dec<1)):next
6005 return
6010 dec=0:fori=len(bin$)to1step-1:r=asc(mid$(bin$,i,1))-48:r=r-abs((r>9))*7
6015 dec=dec+r*b^(len(bin$)-i):next
6020 return
10000 x=x+48:ifx>57thenx=x+8
52000 print"[147][201]llegal [214]alue!":fort=1to1000:next:goto1000
60000 printchr$(18)" ";
60005 printchr$(18)" [204]oadstar [208]resents ";
60010 printchr$(18)" [193]ll [194]ase [195]alculator ";
60015 printchr$(18)" "
60020 print tab( 19)"by"
60060 print : print tab( 15)"[212]om [208]helps"
60070 print : print tab( 13)"[195]opyright 1986"
60090 print " [204]oadstar is not public domain."
60100 print : print " [208]lease respect the author's rights."
60200 print : print tab( 15)"[208]ress a key";:poke198,0:wait198,1:get k$
60300 return
63000 rem re-connect
63010 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
63020 ifer<>63thenend
63030 load"hello connect",8